import DrawBaseItem from './DrawBaseItem';
import {Ellipse} from 'pixi.js';

/**
 * 椭圆
 *
 * EllipseItem
 * 
 * @extends DrawBaseItem
 * @class
 * @memberof Nice.DrawBase
 * @author iwangcj
 */
export default class EllipseItem extends DrawBaseItem 
{
    constructor(x=0, y=0, width=0, height=0) {
        super();

        /**
         * @member {Ellipse}
         * @default {0,0,0,0}
         */
        this.ellipse = new Ellipse(x,y,width,height);

    }


    get x() {
        return this.ellipse.x;
    }

    set x(_x) {
        this.ellipse.x = _x;
    }

    draw() {
        this.drawShape(this.ellipse);
    }

    /**
     * get/set 属性
     * @param {*} key 
     * @param {*} value 
     */
    attr(key, value) {
        if (undefined != value) {
            let isOk = this.attrBase(key, value);
            !isOk && (isOk = this.attrStyle(key, value)); 

            if (isOk) {
                this.draw();
            }
        }
        else {
            let result = this.attrBase(key);
            undefined == result && (result = this.attrStyle(key));
            return result;
        }
    }
}